<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/page_init.jsp"%>
<%@ page import="java.util.Map"%>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Insert title here</title>
	<script type="text/javascript" src="<%=contextPath%>/js/console/md5.js"></script>
</head>
<%
	JSONObject user = (JSONObject) request.getAttribute("user");
%>
<body>
 
   <div class="main-right l">
    <div class="main-right-scroll">
      <div class="title-bt"><span class="pl10">修改密码</span><span class="pr10 tr">
        <button class="btn-28" onclick="back();">返回</button>
        </span></div>
      <div class="right-content">
          <div class="operate-nav">
            <div class="operate-title"><span>密码信息</span></div>
            <div class="operate-contant">
              <table width="100%" border="0" cellspacing="0" cellpadding="0" >
                <tr>
                  <td width="10%" class="mandatory">旧密码:</td>
                  <td width="40%">
                  <input type="password" id="oldPwd" name="oldPwd" class="width-180"/>
                   </td>
                </tr>
                <tr>
                  <td class="mandatory">新密码:</td>
                  <td>
                  	<input type="password" id="newPwd" name="newPwd" class="width-180" />
				<span style="color:green">密码长度：6~20位</span>
                  </td>
                </tr>
                <tr>
                  <td class="mandatory">确认密码:</td>
                  <td>
                  	<input type="password" id="rePwd" name="rePwd" class="width-180" />
                  </td>
                </tr>
              </table>
            </div>
          </div>
          	<input type="hidden" id="id" name="id" value='<%=user.getString("id") %>' />
			<input type="hidden" id="name" name="name" value='<%=user.getString("name") %>' />
			<input type="hidden" id="usertype" name="usertype" value='<%=user.getString("usertype") %>' />
			<input type="hidden" id="loginId" name="loginId" value='<%=user.getString("loginId") %>' />
			<input type="hidden" id="menuIds" name="menuIds" value='<%=user.getString("menuIds") %>' />
        <div class="mt10 mb10 tr"><button class="btn-28" id="update_tpl_btn">保存</button></div>
      </div>
    </div>
  </div>
	<script type="text/javascript">
		$(function() {
			$("#update_tpl_btn").on("click", function() {
				if($("#oldPwd").val()==''){
					apexLayer.Warn("请输入旧密码！");
				}else if($("#newPwd").val()==''){
					apexLayer.Warn("请输入新密码！");
				}else if($("#rePwd").val()==''){
					apexLayer.Warn("请输入确认密码！");
				}else if($("#newPwd").val().length>20||$("#newPwd").val().length<6){
					apexLayer.Warn("密码长度不对，请输入6~20位的新密码");
				}
				else if($("#newPwd").val()==$("#rePwd").val()){
					Ajax({
						url: contextPath+"/console/user/uptSystemUser",
						isMask : true,
						data: {
							"id": $("#id").val(),
							"loginId": $("#loginId").val(),
							"name": $("#name").val(),
							"menuIds": $("#menuIds").val(),
							"usertype": $("#usertype").val(),
							"oldPwd": hex_md5($("#oldPwd").val()),
							"newPwd": hex_md5($("#newPwd").val())
						},
						success: function (data) {
							if (data.success) {
								apexLayer.Msg("修改密码成功！",1000,function(){
									self.parent.window.location = contextPath+"/console/index/main";
								});
							} else {
								apexLayer.Warn(data.note);
								$("#oldPwd").val("");
								$("#rePwd").val("");
								$("#newPwd").val("");
							}
						}
					});
					
					document.getElementById('oldPwd').value=hex_md5($("#oldPwd").val());
					document.getElementById('newPwd').value=hex_md5($("#newPwd").val());
					document.getElementById('rePwd').value=hex_md5($("#rePwd").val());
				}else{
					apexLayer.Warn("密码确认错误，请重新输入！");
				}
			});
		});
		
		function back(){
			self.parent.window.location=contextPath+'/console/index/main';
		}
		
		function checkPwd(){
			
		}
		

	</script>
</body>
</html>